<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>Search By Customer Birthday</title>
    </head>
    <body>
        <div id='reportFormDiv'>
        </div>
        <div id='report_win'>
        </div>
        <script>
            
            Ext.onReady(function(){
                // sex combobox
                var reportWin;
                var reportTypesArray = [['dailysellreport', '日销售报表']];
                var reportTypesReader = new Ext.data.ArrayReader({
                    id: 0
                }, [{
                    name: 'value'
                }, {
                    name: 'key'
                }]);
                var reportTypesStore = new Ext.data.Store({
                    reader: reportTypesReader
                });
                reportTypesStore.loadData(reportTypesArray);
                var report_type = new Ext.form.ComboBox({ //combobox   
                    name: 'report_type',
                    fieldLabel: '报表类型',
                    resiable: true,
                    typeAhead: true,
                    handleHeight: 100, //   
                    displayField: 'key',
                    valueField: 'value',
                    selectOnFocus: true,
                    mode: 'local',
                    hiddenName: 'report_type_value',
                    selectOnFocus: true,
                    triggerAction: 'all',//这个属性非常重要,可以在选择一个值以后,依然还显示其它的值.
                    readOnly: true,
                    emptyText: '选择报表类型...',
					editable: false,
                    store: reportTypesStore, //数据储存到这个comboBox   
                    anchor: '90%',
                    allowBlank: false
                });
                var comfirmButton = new Ext.Button({
                    text: '确定',
                    handler: reportByType
                })
                var reportFormPanel = new Ext.form.FormPanel({
                    baseCls: 'x-plain',
                    labelWidth: 55,
                    width: '600',
                    //url: '/reports/dailySellReport',
                    //defaultType: 'textfield',
                    items: [{
                        layout: 'column',
                        border: false,
                        items: [{
                            columnWidth: .39,
                            layout: 'form',
                            border: false,
                            items: [report_type]
                        }, {
                            columnWidth: .13,
                            layout: 'form',
                            border: false,
                            items: [comfirmButton]
                        }]
                    }]
                });
                reportFormPanel.render('reportFormDiv');
                function reportByType(){
                    if (reportFormPanel.form.isValid()) {
                        //alert(birthdayKey.getValue());
                        var reportType = report_type.getValue();
                        //Ext.MessageBox.alert('Failed', reportType);
                        getReportWindow(reportType);
                    }
                }
                
                function getReportWindow(report_type){
                    var report_url;
                    var report_title;
                    if (report_type == "dailysellreport") {
                        report_url = "/reports/dailySellReportWin";
                        report_title = "销售日报表";
                    }
                    if (!reportWin) {
                        reportWin = new Ext.Window({
                            el: 'report_win',
                            layout: 'fit',
                            width: 770,
                            height: 350,
                            closeAction: 'hide',
                            plain: true,
                            //modal: true,
                            title: report_title,
                            autoLoad: {
                                url: report_url,
                                scripts: true
                            },
                            buttons: [{
                                text: '关闭',
                                handler: function(){
                                    reportWin.hide();
                                }
                            }]
                        });
                    }
                    else {
                        var url = report_url;
                        reportWin.setTitle(report_title);
                        reportWin.getUpdater().update(url);
                    }
                    reportWin.show();
                }
            });
        </script>
    </body>
</html>
